package com.example.system.convert;

import com.example.system.dto.ResetSelfDto;
import com.example.system.dto.UserDto;
import com.example.system.dto.UserInfo;
import com.example.system.dto.WeixinExtraDto;
import com.example.system.entity.User;
import com.example.system.entity.WeixinExtra;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * @author 王令
 * @since 2022/8/5 10:56
 */
@Mapper
public interface UserConvert {

    UserConvert INSTANCE = Mappers.getMapper(UserConvert.class);

    @Mapping(target = "roles", ignore = true)
    @Mapping(target = "authorities", ignore = true)
    UserInfo toUserInfo(User user);

    @Mapping(target = "createTime", ignore = true)
    @Mapping(target = "updateTime", ignore = true)
    @Mapping(target = "deleted", ignore = true)
    @Mapping(target = "deleteTime", ignore = true)
    User toUser(UserDto userDto);


    @Mapping(target = "username", ignore = true)
    @Mapping(target = "updateTime", ignore = true)
    @Mapping(target = "tenantId", ignore = true)
    @Mapping(target = "password", ignore = true)
    @Mapping(target = "nonLocked", ignore = true)
    @Mapping(target = "id", ignore = true)
    @Mapping(target = "gender", ignore = true)
    @Mapping(target = "enabled", ignore = true)
    @Mapping(target = "deleted", ignore = true)
    @Mapping(target = "deleteTime", ignore = true)
    @Mapping(target = "createTime", ignore = true)
    User toUser(ResetSelfDto resetSelfDto);

    WeixinExtraDto toWeixinExtraDto(WeixinExtra extra);

    WeixinExtra toWeixinExtra(WeixinExtraDto weixinExtraDto);
}
